﻿@model VietPremier.Areas.AdminCP.Models.AdminDestinationModel

@{
    ViewBag.Title = "Edit";
    Layout = "~/Areas/AdminCP/Views/Shared/AdminLayout.cshtml";
}

<script type="text/javascript" src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-1.7.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
<script type="text/javascript"  src="@Url.Content("~/ckeditor/ckeditor.js")"></script>
<script type="text/javascript" src="@Url.Content("~/ckfinder/ckfinder.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui-timepicker-addon.js")"></script>
<script type="text/javascript">
    $(function () {
        $("#DateCreate").datepicker();

    });
    jQuery(document).ready(function () {

        $('#nofSuccess').hide(); // an thong bao
        $('#nofError').hide();

        readyValue();
    }); 
   
    function alertMsg(msg) {
        $('#nofSuccess').hide();
        $('#nofError').show();
        $('#msgNofError').text(msg);
    }
    function SEOvalue() {

        $("#Titletag").val("VietPremier Destination");

        $("#Meta_description").val("VietPremier Destination");

        $("#Meta_keyword").val("VietPremier Destination");

        return false;
    }
    function checkField() {       
        var image = $("#Image").val();
        if (image == null || image == "") {
           
        }
        else {
            var ext = image.substring((Math.max(0, image.lastIndexOf(".")) || image.length) + 1);
            ext = ext.toLowerCase();

            if (ext != "jpg" && ext != "jpeg" && ext != "gif" && ext != "png") {

                msg = "! Upload an image file with format jpg, jpeg, gif or png";
                alertMsg(msg);
                $("#Image").css("border", "1px solid red");
                return false;
            }
        }

        return confirm("Bạn có muốn tiếp tục thay đổi không?");
    }
  
</script>
<div class="maincontentinner">

    <ul class="maintabmenu">
       <li><a href="@Url.Action("Index", "AdminDestination",new { id = @ViewBag.IdCountry })" >Quản lý điểm đến du lịch</a></li>
        <li><a href="@Url.Action("Insert", "AdminDestination", new { id = @ViewBag.IdCountry })" >Thêm mới điểm đến du lịch</a></li>
    </ul>
    <!--maintabmenu-->

    <div class="notification msgsuccess" style="display: none" id="nofSuccess">
        <a class="close"></a>
        <p id="msgNofSuccess">This is a success message.</p>
    </div>
    <!-- notification msgsuccess -->

    <div class="notification msgerror" style="display: none" id="nofError">
        <a class="close"></a>
        <p id="msgNofError">This is an error message.</p>
    </div>
    <!-- notification msgerror -->
    
     @using (Html.BeginForm("Edit", "AdminDestination", FormMethod.Post, new { @id = "formCreate", @class = "stdform stdform2", enctype = "multipart/form-data" }))
     {
         @Html.ValidationSummary()
         @Html.HiddenFor(model => model.Id)
         @Html.HiddenFor(model=>model.IdDestinationCountry)
          <div class="contenttitle radiusbottom0">
            <h2 class="table"><span>Quản lý SEO cho trang @Model.Name</span></h2>
        </div>

        <p>
            <label>Title </label>
            <span class="field">
                @Html.TextBoxFor(model => model.Titletag)</span>
        </p>

        <p>
            <label>Meta Description </label>
            <span class="field">
                @Html.TextBoxFor(model => model.Meta_description)</span>
        </p>

        <p>
            <label>Meta Keyword </label>
            <span class="field">
                  @Html.TextAreaFor(model => model.Meta_keyword, new { @cols = 80, rows = 5 })</span>
        </p>
         <p class="stdformbutton" style="padding:10px">
         <input type="submit" value="Sử dụng giá trị SEO mặc định" onclick="return SEOvalue()"/>
             </p>
             <div class="contenttitle radiusbottom0">
            <h2 class="table"><span>Thông tin điểm đến du lịch</span></h2>
        </div>
        <p>
            <label>Tên</label>
            <span class="field">
                @Html.TextBoxFor(model => model.Name)
            </span>
        </p>
         <p>
            <label>Hình ảnh</label>
             @{
         var imageFile = "~/Content/upload/destination/";
         if (Model.Image != null)
         {
             imageFile += Model.Image;
         }
         else
         {
             imageFile += "no-photo.jpg";
         }
            }
            <span class="field">
                <img id="CurrentImage" src= "@Url.Content(imageFile)"  alt="" style="height: 100px; width: 100px" /></span>
        </p>
        <p>
            <label>Thay đổi hình ảnh</label>
            <span class="field">
                <input type="file" name="Image" id="Image" />
            </span>
        </p> 
        <p>
            <label>Tỉnh thành</label>
            <span class="field">
                @Html.TextBoxFor(model => model.Duration)
            </span>
        </p>
         <p>
            <label>Mô tả</label>
            <span class="field">
                <textarea class="longinput" rows="5" cols="80" name="Description" id="Description">@Model.Description</textarea>
            </span>
        </p>
         <p>
            <label>Nội dung</label>
            <span class=" field">
                <textarea cols="80" rows="5" name="Body" id="Body" class="longinput">@Model.Body</textarea>
            </span>
            <script type="text/javascript">
                CKEDITOR.replace('Body', {
                    filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
                    filebrowserImageBrowseUrl: '/ckfinder/ckfinder.html?Type=Images',
                    filebrowserFlashBrowseUrl: '/ckfinder/ckfinder.html?Type=Flash',
                    filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                    filebrowserImageUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                    filebrowserFlashUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
                });
            </script>
        </p>  
         <p>
            <label>Ngày Tạo</label>
            <span class="field">
                <input type="text" name="DateCreate" id="DateCreate" value="@Model.DateCreate" readonly="true"/>
            </span>
        </p>
        <p class="stdformbutton">
            <input type="submit" value="Chấp nhận" onclick="return checkField()" />
            <input type="submit" value="Trở lại" onclick="javascript: history.back(); return false" />
        </p>

     }

    <br clear="all" />

</div>

